<?php


namespace app\admin\model;


use think\Model;

class Card extends Model
{
    protected $autoWriteTimestamp = true;

    public static function add($userNo,$staffNo,$mobile)
    {
//        $res = Card::where("user_no",$userNo)->where("staff_no",$staffNo)->find();
//        if(!$res){
//            $arr = ["user_no"=>$userNo,"staff_no"=>$staffNo,"mobile"=>$mobile];
//            Card::create($arr);
//        }else{
//            Card::where("id",$res["id"])->data(["mobile"=>$mobile])->update();
//        }
        $arr = ["user_no"=>$userNo,"staff_no"=>$staffNo,"mobile"=>$mobile];
        Card::create($arr);
        return "";
    }

    public static function ifExCard($mobile):bool
    {
        $res = Card::where("mobile",$mobile)->whereBetweenTime("create_time",date("Y-m-d"))->value("id");
        if($res)return true;
        return false;
    }
}